use JPP_Vacancy, clear

**NEED opp_deg_chair
**ALSO check that current opp_deg measures are correct
**RCL Models
zinb vacant_days c.opp_deg_senate##c.opp_deg_senate c.opp_deg_pres ///
c.lag_std i.high_status i.ig i.newadministration c.margin /// 
c.selin1_std i.house_divided c.committee_conflict i.president_num, /// 
inflate(c.opp_deg_senate##c.opp_deg_senate c.opp_deg_pres /// 
c.lag_std i.high_status i.ig i.newadministration c.margin /// 
c.selin1_std i.house_divided c.committee_conflict i.president_num) cluster(position_id) nolog

listcoef c.lag_std i.high_status i.ig i.newadministration /// 
c.margin c.opp_deg_senate c.opp_deg_pres /// 
c.selin1_std i.house_divided c.committee_conflict, percent help

fitstat

su opp_deg_senate, d
su opp_deg_pres, d

margins high_status, at(margin=(-12(1)18))
marginsplot, scheme(s1mono) legend(position(1) ring(0))

margins high_status, at(opp_deg_senate=(0(.3)2.2))
marginsplot, scheme(s1mono) legend(position(1) ring(0))

margins high_status, at(opp_deg_pres=(0(.3)2.1))
marginsplot, scheme(s1mono) legend(position(1) ring(0))

su vacant_days lag1 ideodiff_majmed_adj ideodiff_chair_adj ideodiff_pres_adj /// 
high_status ig newadministration margin committee_conflict house_divided selin1

pwcorr vacant_days lag1 ideodiff_majmed_adj ideodiff_chair_adj ideodiff_pres_adj /// 
high_status ig newadministration margin committee_conflict house_divided selin1

***CJ Models
**chair and maj med squared, pres control
zinb vacant_days c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj i.high_status /// 
c.margin c.lag_std i.ig i.newadministration c.selin1_std /// 
c.committee_conflict i.house_divided i.president_num, /// 
inflate(c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj i.high_status c.margin c.lag_std /// 
i.ig i.newadministration c.selin1_std c.committee_conflict /// 
i.house_divided i.president_num) cluster(agency_sub) nolog

fitstat

listcoef 

eststo CJ1

su ideodiff_majmed_adj, d
su ideodiff_pres_adj, d
su ideodiff_chair_adj, d

margins high_status, at(ideodiff_majmed_adj=(-.7(.1).2))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_majmed, replace)

margins high_status, at(ideodiff_pres_adj=(-.9(.1)0))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_pres, replace)

margins high_status, at(ideodiff_chair_adj=(-.9(.1).6))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_chair, replace)

margins president_num, at(ideodiff_majmed_adj=(-.7(.1).2))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) name(status_majmed_bypres, replace)

margins president_num, at(ideodiff_chair_adj=(-.9(.1).6))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) name(status_chair_bypres, replace)

graph combine status_majmed_bypres status_chair_bypres


**chair and maj med squared, pres control (using average CJ scores)
zinb vacant_days c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj i.high_status /// 
c.margin c.lag_std i.ig i.newadministration c.selin1_std /// 
c.committee_conflict i.house_divided i.president_num, /// 
inflate(c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj i.high_status c.margin c.lag_std /// 
i.ig i.newadministration c.selin1_std c.committee_conflict /// 
i.house_divided i.president_num) cluster(agency_sub) nolog

fitstat

listcoef, percent

eststo CJ1avg

su ideodiff_majmed_avg_adj, d
su ideodiff_pres_avg_adj, d
su ideodiff_chair_avg_adj, d

margins high_status, at(ideodiff_majmed_avg_adj=(-.7(.1).2))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_majmed_avg, replace)

margins high_status, at(ideodiff_pres_avg_adj=(-.9(.1)0))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_pres_avg, replace)

margins high_status, at(ideodiff_chair_avg_adj=(-.9(.1).6))
marginsplot, scheme(s1mono) legend(position(1) ring(0)) saving(status_chair_avg, replace)

esttab CJ1 CJ1avg using JPP_main.csv, replace /// 
	se ///
	title(Zero Inflated Negative Binomial Results) ///
	coeflabels(	high_status "High Status Position" /// 
				agency_head "Agency Head" ///
				ig "Inspector General" ///
				newadministration "New Administration" ///
				margin_std "Partisan Margin in Senate" ///
				ideodiff_majmed_adj "Senate-Agency Divergence" ///
				ideodiff_majmed_adj "President-Agency Divergence" ///
				high_conflict "High Committee/President Conflict") ///
	nocons ///
	nonumbers ///
	nomtitles ///
	nowrap ///
	varwidth(30) ///
	starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)


**chair and maj med squared, pres control (no other controls)
zinb vacant_days c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj i.high_status, /// 
inflate(c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj c.ideodiff_majmed_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ2

**chair and maj med squared, pres control (no other controls)
zinb vacant_days c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj i.high_status, /// 
inflate(c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
c.ideodiff_pres_adj c.ideodiff_majmed_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ3

**chair squared and high status (no other controls)
zinb vacant_days c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
i.high_status, /// 
inflate(c.ideodiff_chair_adj##c.ideodiff_chair_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ4

**maj med squared and high status (no other controls)
zinb vacant_days c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
i.high_status, /// 
inflate(c.ideodiff_majmed_adj##c.ideodiff_majmed_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ5

esttab CJ2 CJ3 CJ4 CJ5 using JPP_appendix.csv, replace /// 
	se ///
	title(Zero Inflated Negative Binomial Results) ///
	coeflabels(	high_status "High Status Position" /// 
				agency_head "Agency Head" ///
				ig "Inspector General" ///
				newadministration "New Administration" ///
				margin_std "Partisan Margin in Senate" ///
				ideodiff_majmed_adj "Senate-Agency Divergence" ///
				ideodiff_majmed_adj "President-Agency Divergence" ///
				high_conflict "High Committee/President Conflict") ///
	nocons ///
	nonumbers ///
	nomtitles ///
	nowrap ///
	varwidth(30) ///
	starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)

**CJAVG ROBUSTNESS CHECKS
**chair and maj med squared, pres control (no other controls)
zinb vacant_days c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj i.high_status, /// 
inflate(c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj c.ideodiff_majmed_avg_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ2A

**chair and maj med squared, pres control (no other controls)
zinb vacant_days c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj i.high_status, /// 
inflate(c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
c.ideodiff_pres_avg_adj c.ideodiff_majmed_avg_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ3A

**chair squared and high status (no other controls)
zinb vacant_days c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
i.high_status, /// 
inflate(c.ideodiff_chair_avg_adj##c.ideodiff_chair_avg_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ4A

**maj med squared and high status (no other controls)
zinb vacant_days c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
i.high_status, /// 
inflate(c.ideodiff_majmed_avg_adj##c.ideodiff_majmed_avg_adj /// 
i.high_status) cluster(agency_sub) nolog

eststo CJ5A

esttab CJ2A CJ3A CJ4A CJ5A using JPP_appendix_avg.csv, replace /// 
	se ///
	title(Zero Inflated Negative Binomial Results) ///
	coeflabels(	high_status "High Status Position" /// 
				ideodiff_majmed_avg_adj "Majority Median-Agency Divergence" ///
				ideodiff_chair_avg_adj "Chair-Agency Divergence" ///
				ideodiff_pres_avg_adj "President-Agency Divergence") ///
	nocons ///
	nonumbers ///
	nomtitles ///
	nowrap ///
	varwidth(30) ///
	starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)



